<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="com.database.DBManage"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>搜索课程</title>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
  <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<%

String student_id="41901001";


		request.setCharacterEncoding("utf-8");
		String sql="select student_name,student_img from student where student_id="+student_id+" ";
		javax.sql.rowset.WebRowSet rx=DBManage.query(sql);
		
%>
<%
	while(rx.next()){
		String student_name=rx.getString("student_name");
		String student_img=rx.getString("student_img");
			%>
<nav class="navbar navbar-light bg-light">
  <a class="navbar-brand" href="student.jsp">首页</a>
   <a class="navbar-brand" href="suser.jsp">
    <img src="<%= student_img %>" width="30" height="30" alt=""><%=student_name %>
  </a>
</nav>
<%
	}
	rx.close();

	%>
<%
		request.setCharacterEncoding("utf-8");
	    String key=request.getParameter("keywards");
		String sql1="";
		if(key!=null&&key.length()>0){
			sql1+="select a.teach_class_name,b.teacher_name,a.stu_number,a.stu_number_max,a.teach_course_detail from teach_class a,teacher b where a.teacher_id=b.teacher_id and a.teach_class_name like'%" +key+ "%'";
		}
		javax.sql.rowset.WebRowSet rs=DBManage.query(sql1);
	%>
<nav class="navbar navbar-expand-lg navbar-light bg-white" style="padding-top:50px;">
    <form class="form-inline my-2 my-lg-0" method="post">
      <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" name="keywards"  value="<%=(key!=null? key:"") %>">
      <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
    </form>
</nav>

<% 
		while(rs.next()){
			String teacher_name=rs.getString("teacher_name");
			String teach_class_name=rs.getString("teach_class_name");
			String teacher_name2 =rs.getString("teacher_name");
			String stu_number=rs.getString("stu_number");
			String teach_course_detail=rs.getString("teach_course_detail");
			String stu_number_max=rs.getString("stu_number_max");
			%>
<nav class="navbar navbar-expand-lg navbar-light bg-light" style="margin-top:20px">
  <h4><%=teach_class_name%></h4>
  

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <h6 style="margin-left:20px"> <%=teacher_name%><span class="sr-only">(current)</span></h6>
      </li>
    </ul>
    <button type="submit" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">
查看详情
</button>

<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalCenterTitle">具体信息</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <div style="padding-left:50px;padding-right:50px" >
  <form action="AddclassServlet" method="post">
  <table class="table table-bordered" >
  <tbody>
    <tr>
      <td >课程名称</td>
      <td ><%=teach_class_name %></td>
    </tr>
    <tr>
      <td >教学老师</td>
      <td ><%=teacher_name %></td>
    </tr>
    <tr>
      <td >容量上限</td>
      <td ><%=stu_number_max %></td>
    </tr>
    <tr>
      <td >已选人数</td>
      <td ><%=stu_number %></td>
    </tr>
    <tr>
      <td>课程简介</td>
      <td><%=teach_course_detail %></td>
    </tr>
    <input type="hidden" name="student_id" value="41901001">
    <tr>
      <td colspan="2" style="text-align:center;"><input type="submit" name="OK" value="加入课程" /></td>
    </tr>
  </tbody>
</table>
</form>
</style>
</div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>
      </div>
    </div>
  </div>
</div>
  </div>
  </ol>
</nav>
<%
	}
	rs.close();

	%>
</body>
</html>